<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<title>工序报工</title>
		<link rel="stylesheet" type="text/css" href="../css/api.css"/>
		<link rel="stylesheet" type="text/css" href="../css/aui.css" />
		<link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
		<link rel="stylesheet" type="text/css" href="../css/aui-flex.css" />
		<link rel="stylesheet" type="text/css" href="../css/aui-list-swipe.css" />
		<link rel="stylesheet" type="text/css" href="../css/isDialog.css" />
		<link rel="stylesheet" type="text/css" href="../../layui/css/layui.css" media="all" />

		<style type="text/css">

		</style>
	</head>
	<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            工序报工
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <ul class="aui-list aui-form-list">

            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">良品数量</div>
                    <div class="aui-list-item-input">
                        <input type="number" id="effectiveQty" type="number">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">不良品数量</div>
                    <div class="aui-list-item-input">
                        <input type="number" id="uneffectiveQty" type="number">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">报废数量</div>
                    <div class="aui-list-item-input">
                        <input type="number" id="discardQty" type="number">
                    </div>
                </div>
            </li>
        </ul>
        <p></p>
        <p></p>
        <div class="aui-btn aui-btn-info aui-btn-block" onclick="save()">保存</div>

	</body>
	<script type="text/javascript" src="../script/api.js"></script>
	<script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="../script/isDialog.js"></script>
	<script type="text/javascript" src="../script/api.js"></script>
	<script type="text/javascript" src="../script/doT.min.js"></script>
	<script type="text/javssssascript" src="../script/zepto.min.js"></script>
	<script type="text/javascript" src="../script/aui-list-swipe.js"></script>
	<script type="text/javascript" src="../script/public.js"></script>
	<script src="../script/swiper.min.js"></script>
	<script type="text/javascript">

		apiready = function() {
			// trackId = api.pageParam.trackId;
}
function save(){
  	var effectiveQty = $("#effectiveQty").val();
    var uneffectiveQty = $("#uneffectiveQty").val();
    var discardQty = $("#discardQty").val();
  if(effectiveQty==null||effectiveQty==""||effectiveQty<0){
		api.toast({
				msg: "请录入良品数",
				duration: 3000
		});
    api.hideProgress();
    return;
  }
  api.showProgress({
      title: '数据加载中...',
      text: '请稍等...',
      duration:15000,
  });
  var un = localStorage.getItem('un');
  var serverUrl = localStorage.getItem('serverUrl');
  var url = serverUrl + "/app/setPaDaqInfoState";
  var params = new Object();
  params.url = url;
  params.method = 'post';
  params.dataType = 'json';
  var data = {
    values : {
      un:un,
      trackId : api.pageParam.trackId,
      operateType:'3',
      effectiveQty:effectiveQty==null||effectiveQty==""?0:effectiveQty,
      uneffectiveQty:uneffectiveQty==null||uneffectiveQty==""?0:uneffectiveQty,
      discardQty:discardQty==null||discardQty==""?0:discardQty
    }
  };
  api.ajax({
      url: url,
      method: 'post',
      dataType: 'json',
      timeout: 300,
      returnAll: false,
      data: data
  }, function(ret, err) {
      if (ret) {
          var data = JSON.stringify(ret);
          var myobj = eval("(" + data + ")");
          //返回成功
          if (myobj.code == "0") {

              api.hideProgress();

							api.closeWin({
							});
							api.execScript({
									name: api.pageParam.name,
									script: 'getTabList()'
							});

              // api.closeFrame();

              //失败
          } else if (myobj.code == "1") {
              api.hideProgress();
              api.toast({
                  msg: myobj.message,
                  duration: 3000
              });
          }
      }
  });
}
//返回按钮
function closeWin() {
		api.closeWin({});
}
	</script>
</html>
